package com.itheima.leetcode.od.c.logicalsimulation;

import java.util.Scanner;

/**
 * <h3>掌握单词的个数</h3>
 */
public class MasteringWordsNumber {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine());
        String[] words = new String[n];
        for (int i = 0; i < n; i++) {
            words[i] = in.nextLine();
        }

        char[] chars = in.nextLine().toCharArray();
        int[] char_count_map = new int[26];
        int maigc_char_count = 0;
        int j = 0;
        while (j < chars.length) {
            if (chars[j] == '?') {
                maigc_char_count += 1;
            } else {
                char_count_map[chars[j] - 'a'] += 1;
            }
            j += 1;
        }

        int output_count = 0;
        int i = 0;
        while (i < n) {
            int[] word_count_map = new int[26];
            for (int k = 0; k < words[i].toCharArray().length; k++) {
                word_count_map[words[i].toCharArray()[k] - 'a'] += 1;
            }

            boolean flag = true;
            int temp_count = maigc_char_count;
            for (int k = 0; k < 26; k++) {
                if (word_count_map[k] - char_count_map[k] > 0) {
                    temp_count -= word_count_map[k] - char_count_map[k];
                    if (temp_count < 0) {
                        flag = false;
                        break;
                    }
                }
            }
            if (flag) {
                output_count++;
            }
            i += 1;
        }

        System.out.println(output_count);
    }
}